home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 August: Tool Chest / Dev.CD Aug 00 TC Disk 2.toast / pc / sample code / interapplication comm / moreappleevents / filehelpers.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-06-23  |  3.1 KB  |  125 lines

  1. /*
  2.     File:        FileHelpers.h
  3.  
  4.     Contains:    Functions to help you when working with files.
  5.  
  6.     Written by: Andy Bachorski    
  7.  
  8.     Copyright:    Copyright © 1996-1999 by Apple Computer, Inc., All Rights Reserved.
  9.  
  10.                 You may incorporate this Apple sample source code into your program(s) without
  11.                 restriction. This Apple sample source code has been provided "AS IS" and the
  12.                 responsibility for its operation is yours. You are not permitted to redistribute
  13.                 this Apple sample source code as "Apple sample source code" after having made
  14.                 changes. If you're going to re-distribute the source, we require that you make
  15.                 it clear in the source that the code was descended from Apple sample source
  16.                 code, but that you've made changes.
  17.  
  18.     Change History (most recent first):
  19.                 7/21/1999    Karl Groethe    Updated for Metrowerks Codewarror Pro 2.1
  20.                 
  21.  
  22. */
  23.  
  24. #if PRAGMA_ONCE
  25.     #pragma once
  26. #endif
  27.  
  28. #ifndef _FILE_HELPERS_
  29. #define _FILE_HELPERS_
  30.  
  31.  
  32. //******************************************************************************
  33. //    A private conditionals file to setup the build environment for this project.
  34.  
  35. #include "PrivateConditionals.h"
  36.  
  37.  
  38. //**********    Universal Headers        ****************************************
  39.  
  40. #include <AppleEvents.h>
  41. #include <Files.h>
  42.  
  43.  
  44. //******************************************************************************
  45.  
  46. #ifdef __cplusplus
  47.     extern "C" {
  48. #endif
  49.  
  50. #if PRAGMA_IMPORT
  51.     #pragma import on
  52. #endif
  53.  
  54. #if PRAGMA_STRUCT_ALIGN
  55.     #pragma options align=mac68k
  56. #elif PRAGMA_STRUCT_PACKPUSH
  57.     #pragma pack(push, 2)
  58. #elif PRAGMA_STRUCT_PACK
  59.     #pragma pack(2)
  60. #endif
  61.  
  62. //******************************************************************************
  63.  
  64.  
  65.  
  66. OSErr OpenResFileForWrite( const FSSpec *fileFSSPtr, SInt16 *iconResFileRef );
  67. /*
  68.  
  69.     Given an FSSpec to a file, open it with write permission.
  70.     Check to make sure that the file reference returned actually has write
  71.     permission and return an error if it doesn't.
  72.  
  73.     fileFSSPtr        input:    The file to be opened.
  74.     SInt16            output:    File reference for the newly opened file.
  75.     
  76.     RESULT CODES
  77.     ____________
  78.         Same as results for FSpOpenResFile()
  79.     ____________
  80. */
  81.  
  82. //******************************************************************************
  83.  
  84. Boolean IsResourceFileRefNumWritable( SInt16 refNum );
  85. /*
  86.     Utility routine to check that a file opened with read/write permission
  87.     does in fact have read/write permission.
  88.     
  89.     It is possible to get a read-only file reference for a resource file that has
  90.     been opened with read/write permission.  This routine verify that a file open
  91.     with read/write permission does in fact have write permission.
  92.  
  93.     refNum            input:    File reference number for file to be checked.
  94.     
  95.     RESULT CODES
  96.     ____________
  97.         true        The resource file was really opened with write permission
  98.         false        It wasn't
  99.     ____________
  100. */
  101.  
  102.  
  103. //******************************************************************************
  104.  
  105.  
  106. #if PRAGMA_STRUCT_ALIGN
  107.     #pragma options align=reset
  108. #elif PRAGMA_STRUCT_PACKPUSH
  109.     #pragma pack(pop)
  110. #elif PRAGMA_STRUCT_PACK
  111.     #pragma pack()
  112. #endif
  113.  
  114. #ifdef PRAGMA_IMPORT_OFF
  115. #pragma import off
  116. #elif PRAGMA_IMPORT
  117. #pragma import reset
  118. #endif
  119.  
  120. #ifdef __cplusplus
  121. }
  122. #endif
  123.  
  124. #endif // _FILE_HELPERS_
  125.